package com.jinsi.service.lv.iml;

import com.jinsi.constant.LhrConstant;
import com.jinsi.mapper.lv.OrderMapper;

import com.jinsi.pojo.Order;
import com.jinsi.pojo.OrderList;

import com.jinsi.service.lv.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Service
public class OrderServicelmpl implements OrderService {

    @Autowired
    private OrderMapper orderMapper;

    @Override
    @Transactional
    public List<Order> getOrder(Order order) {
        order.setOrderType(LhrConstant.ORDER_GOODS);
        return orderMapper.getOrder(order);
    }

    /**
     *     查看全部订单
     */
    @Transactional
    @Override
    public List<Order> getAll() {
        return orderMapper.getAll();
    }


    /**修改地址
     *
     * @param orderId
     * @param orderSite
     * @param orderCity
     * @param orderDistrict
     * @param orderDetail
     */
    @Transactional
    @Override
    public void getOrderSiteAmend(Integer orderId, String orderSite, String orderCity, String orderDistrict, String orderDetail) {
        orderMapper.getOrderSiteAmend(orderId, orderSite, orderCity, orderDistrict, orderDetail);
    }

    @Override
    @Transactional
    public void confirm(int orderId) {
        orderMapper.confirm(orderId,LhrConstant.ORDER_FIVE);
    }

    @Override
    @Transactional
    public void addRess(Order order) {
        orderMapper.addRess(order);
    }

    @Override
    @Transactional
    public List<Order> getCurr(Order order) {
        order.setOrderType(LhrConstant.ORDER_VIDEO);
        return orderMapper.getCurr(order);
    }

    @Override
    @Transactional
    public Order viewCourses(Integer orderId) {

        return orderMapper.viewCourses(orderId,LhrConstant.ORDER_VIDEO);
    }

    @Override
    @Transactional
    public List<Order> getReturnList(List<Integer> orderStatus,Order order) {
        order.setOrderStatuss(orderStatus);
        order.setOrderType(LhrConstant.ORDER_GOODS);
        List<Order> getreturnlist = orderMapper.getReturnList(order);
        return getreturnlist;
    }

    @Override
    @Transactional
    public List<OrderList> goodsCensus() {
        return orderMapper.goodsCensus(LhrConstant.ORDER_GOODS);
    }

    @Override
    @Transactional
    public List<OrderList> courseCensus() {
        return orderMapper.courseCensus(LhrConstant.ORDER_VIDEO);
    }

    @Override
    @Transactional
    public List<OrderList> refundCensus() {
        List<Integer> list = new ArrayList<>();
        list.add(LhrConstant.ORDER_SEVEN);
        list.add(LhrConstant.ORDER_EIGHT);
        list.add(LhrConstant.ORDER_NINE);
        list.add(LhrConstant.ORDER_ELEVEN);
        return orderMapper.refundCensus(list);
    }

}
